class Singleton {
  //定义私有静态属性，来保存对象实例
  private static singleton: Singleton;
  private constructor() {}

  //提供一个静态方法回去对象实例
  public static getInstance(): Singleton {
      if(!Singleton.singleton){
          Singleton.singleton = new Singleton();
      }
      return Singleton.singleton;
  }
}

let instance1 = Singleton.getInstance();
